package com.bawei.zk_01

import android.graphics.Color
import android.os.Bundle
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.fragment.app.Fragment
import androidx.viewpager2.widget.ViewPager2.OnPageChangeCallback
import com.bawei.base.utils.mvvm.BaseViewActivity
import com.bawei.zk_01.adapter.MyFmAdapter
import com.bawei.zk_01.adapter.MyTab
import com.bawei.zk_01.databinding.ActivityMainBinding
import com.bawei.zk_01.fm.BlankFragment1
import com.bawei.zk_01.fm.BlankFragment2
import com.bawei.zk_01.fm.BlankFragment3
import com.flyco.tablayout.listener.CustomTabEntity
import com.flyco.tablayout.listener.OnTabSelectListener

class MainActivity : BaseViewActivity<ActivityMainBinding>() {

    lateinit var myFmAdapter: MyFmAdapter
    val list = ArrayList<Fragment>()

    override fun getLayout(): Int {
        return R.layout.activity_main
    }

    override fun initView() {

        list.add(BlankFragment1())
        list.add(BlankFragment2())
        list.add(BlankFragment3())
        myFmAdapter =MyFmAdapter(this,list)
        binding.v2.adapter = myFmAdapter

        val arrayList = ArrayList<CustomTabEntity>()
        arrayList.add(MyTab("",R.drawable.baseline_horizontal_rule_24,R.drawable.baseline_circle_24))
        arrayList.add(MyTab("",R.drawable.baseline_horizontal_rule_24,R.drawable.baseline_circle_24))
        arrayList.add(MyTab("",R.drawable.baseline_horizontal_rule_24,R.drawable.baseline_circle_24))
        binding.tab.setTabData(arrayList)
        binding.tab.indicatorHeight = 0f
        binding.tab.indicatorWidth = 0f

        binding.tab.setOnTabSelectListener(object : OnTabSelectListener {
            override fun onTabSelect(position: Int) {
                binding.v2.currentItem = position
            }

            override fun onTabReselect(position: Int) {

            }
        })

        binding.v2.registerOnPageChangeCallback(object : OnPageChangeCallback() {
            override fun onPageSelected(position: Int) {
                super.onPageSelected(position)
                binding.tab.currentTab = position
            }
        })

    }

    override fun initData() {

    }

}